import Vue from 'vue'
import Vuex from 'vuex'
import loginStore from '@/views/auth/login/assets/index.store.js'
import systemStore from './modules/systemStore.js'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [
    createPersistedState({
      paths: ['loginStore']
      // 这里指定需要持久化的模块路径，例如'moduleA.state1'表示'moduleA'模块中的'state1'状态
      // reducer(val) {
      //   return {
      //     state1: val.moduleA.state1,
      //     state2: val.moduleB.state2
      //     // 只返回需要持久化的状态
      //   };
      // }
    })
  ],
  state() {
    return {
      mapReady: false,
      // 图层显示模式 1=卫星图，2=矢量图
      layerType: 1
    }
  },
  mutations: {
    SET_MAPREADY: state => {
      state.mapReady = true
    },
    SET_LAYERTYPE: (state, layerType) => {
      state.layerType = layerType
    }
  },
  actions: {},
  getters: {
    mapReady: state => state.mapReady,
    layerType: state => state.layerType
  },
  modules: {
    loginStore,
    systemStore
  }
})
